package fonkin.com.wifisignapp.utils;

import android.graphics.Bitmap;
import android.util.Base64;

import java.io.ByteArrayOutputStream;

/**
 * Created by 黄洪靖 on 2017/5/23.
 */

public class PicUtil {

    //Bitmap转成String类型
    public String getStringImage(Bitmap bpm){


        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        bpm.compress(Bitmap.CompressFormat.JPEG,100,baos);
        byte[]imagBytes = baos.toByteArray();
        String encodeImage = Base64.encodeToString(imagBytes,Base64.DEFAULT);
        return encodeImage;
    }



    /**
     * 将Bitmap转换成指定大小
     *
     * @param bitmap 需要改变大小的图片
     * @param width  宽
     * @param height 高
     * @return
     */
    public static Bitmap createBitmapBySize(Bitmap bitmap, int width, int height) {
        return Bitmap.createScaledBitmap(bitmap, width, height, true);
    }
}
